package com.hu.zhcc.shiro.service.Lixueseng520;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hu.zhcc.common.entity.Page;
import com.hu.zhcc.shiro.dao.LxsProgramDAO;
import com.hu.zhcc.shiro.dao.LxsProgramSortDAO;
import com.hu.zhcc.shiro.entity.bo.Lixueseng520.LxsProgram;
import com.hu.zhcc.shiro.entity.bo.Lixueseng520.LxsProgramSort;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ProgramServiceImpl implements ProgramService {
    @Autowired
    private LxsProgramDAO dao;
    @Autowired
    private LxsProgramSortDAO sortDAO;

    @Override
    public Page<LxsProgram> findProgramByPrimary(Map map,Integer offset,Integer limit) {
        PageHelper.startPage(offset,limit);
        List<LxsProgram> programList = dao.findProgramByPrimary(map);
        for (LxsProgram lxsProgram : programList) {
            System.out.println(lxsProgram);
        }
        PageInfo<LxsProgram> info = new PageInfo<>(programList);
        return new Page<LxsProgram>(info.getTotal(),programList);
    }

    @Override
    public int insertSelective(LxsProgram record) {
        return dao.insertSelective(record);
    }

    @Override
    public int updateByPrimaryKeySelective(LxsProgram record) {
        return dao.updateByPrimaryKeySelective(record);
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return dao.deleteByPrimaryKey(id);
    }

    @Override
    public List<LxsProgramSort> findProgramSort() {
        return sortDAO.findProgramSort();
    }
}
